package clear

import (
	"fmt"
	"os"
	"os/exec"
	"runtime"
)

// ClearScreen 清屏函数，根据不同的操作系统选择不同的清屏命令
func ClearScreen() {
	switch runtime.GOOS {
	case "linux", "darwin":
		cmd := exec.Command("clear")
		cmd.Stdout = os.Stdout
		err := cmd.Run()
		if err != nil {
			return
		}
	case "windows":
		cmd := exec.Command("cmd", "/c", "cls")
		cmd.Stdout = os.Stdout
		err := cmd.Run()
		if err != nil {
			return
		}
	default:
		fmt.Println("Unsupported platform, cannot clear screen")
	}
}
